package com.yami.shop.distribution.api.controller;

import com.yami.shop.common.config.Constant;
import com.yami.shop.common.response.ServerResponseEntity;
import com.yami.shop.distribution.common.dto.DistributionRecruitSetDto;
import com.yami.shop.distribution.common.vo.DistributionRecruitConfigVO;
import com.yami.shop.service.SysConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yami.shop.common.util.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * @author yami
 */
@RestController
@RequestMapping("/p/distribution/recruit")
@Tag(name = "分销推广接口")
public class DistributionRecruitSetController {

    @Autowired
    private SysConfigService sysConfigService;


    @GetMapping("/info")
    @Operation(summary =  "获取店铺推广数据" ,description = "根据店铺id获取")
    public ServerResponseEntity<DistributionRecruitSetDto> info(){
        DistributionRecruitConfigVO distributionRecruitConfigVO = sysConfigService.getSysConfigObject(Constant.DISTRIBUTION_RECRUIT_CONFIG, DistributionRecruitConfigVO.class);
        if (Objects.equals(0,distributionRecruitConfigVO.getState())) {
            distributionRecruitConfigVO.setContent("");
        }
        return ServerResponseEntity.success(BeanUtil.map(distributionRecruitConfigVO, DistributionRecruitSetDto.class));
    }
}
